home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 41
/
Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso
/
Aminet
/
comm
/
tcp
/
jl_update.lha
/
Jl_update.rexx
< prev
Wrap
OS/2 REXX Batch file
|
2000-11-14
|
3KB
|
167 lines
/* Just linux Dyn DNS updater v2 v1.4
**
**
** Requriments
**
** rxsocket installede
**
**
** version 1.1
** addet the ability to update the env:TIADCC , requested by Xpoint
** added the ability to send a offline requeste to justlinux.com, requested by Xpoint
**
** version 1.2
** changede the script so that It will let justlinux.com find your IP itself
** and then we resolve your host name to get the ip for the TIADCC funktion.
**
** version 1.3
** changede the script so that It will let justlinux.com find your IP itself
** and then extract our IP from the returned package from the server for use
** in TIADCC. Now it`s working ;)
**
** version 1.4
** bug fixed
**
** (C) 2000 Jacob Dahl Pind aka Rachael/Copy`n`Paste Tech.
**
**
**
**
*/
/* config space */
user="rachael"
password="dianoga"
/* host */
host="rachael.penguinpowered.com"
/*
**
** overrideip = 1 for overriding the automatical fetchede ip
** replace with 0 for using the fetchede ip
**
** might be usefull if your machine is on a lan
**
** settia = 1 for automatical set ENV:TIADCC
** replace with 0 to disable
**
** remember to change tia_sport and tia_eport
**
**
*/
overrideip="0"
settia="1"
ip="200.000.000.000"
tia_sport="1024"
tia_eport="1025"
/* don`t mess with the code below */
defaultserver = "www.justlinux.com"
urlprefix = "/bin/controlpanel/dyndns/jlc.pl?direct=1"
Parse arg offline
call addlib("rxsocket.library",0,-30,0)
/* check for offline argument and set the IP to something bogus */
if (datatype(offline,ALPHANUMERIC)) THEN DO
ip=127.0.0.1
overrideip="1"
call send_post
end
if ~(datatype(offline,ALPHANUMERIC)) THEN DO
call send_post
say "setting TIADCC"
call set_tiadcc
end
exit
send_post:
if ~Open("STDERR","CONSOLE:","W") then SDTERR="STDOUT"
sin.addraddr=resolve(defaultserver)
if sin.addraddr=-1 then call err "host <"host"> not found",1
sin.addrport=80
sock=socket("INET","STREAM")
if sock=-1 then call err "can't create socket"
if connect(sock,"SIN")<0 then call err "can't connect"
fin="D0A"x
/* let the justlinux.com server find out access point ip */
if ~(overrideip) then do
ip='auto'
end
request="GET" space(urlprefix'&username='user'&password='password'&host='host'&ip='ip) "HTTP/1.0"fin
request=request||fin
say "sending request..."
if send(sock,request)<0 then call err "error sending"
say "receiving results..."
if recvline(sock,"BUF",256)<0 then call err "error receiving"
if buf="" then call err "empty answer",1
parse var buf http code
if word(code,1)~=200 then call err "error from server" code,1
say "receiving head..."
do while buf~="D0A"x
if recvline(sock,"BUF",256)<0 then call err "error receiving"
end
say "receiving file..."
res=recv(sock,"BUF",256)
/* extracter our Ip from the return package from the server */
ip=subword(buf,4,1)
ip=SUBSTR(ip,1,(Length(ip)-1) )
do while res>0
call writech("STDOUT",buf)
res=recv(sock,"BUF",256)
end
if res<0 then call err "error receiving"
say "done."
return
/* Update TIADCC if our Mistress said so */
set_tiadcc:
if (settia) then do
open(tia,'ENV:TIADCC','W')
tias=ip' '||tia_sport' '||tia_eport
writeln(tia,tias)
close(tia)
return
/* error handling procedure */
err: Procedure Expose socket
parse arg msg
If IsLibOn('SOCKET') Then If errno() == 4 Then msg = 'timeout'
Say 'jldyndns :' msg
Exit